/*
 * serialport.h
 *
 *  Created on: 2011-8-29
 *      Author: chenl
 *     Purpose:
 *        Note:
 */

#ifndef SERIALPORT_H_
#define SERIALPORT_H_

#include "common_connect.h"
#include "type_def.h"

typedef struct tagSerialPortSetting
{
	char szPortName[256];
	int32_t nBaudrate;
	unsigned char nByteSize;
	char	chParity;
	unsigned char nStopBits;
	int32_t nTimeout;
}SerialPortSetting;

class CSerialPort : CConnect
{
public:
	CSerialPort();
	virtual ~CSerialPort();
public:
	virtual int32_t Connect(int fd = enmInvalidFD);
	virtual int32_t DisConnect();

	virtual uint32_t Recv(char *pszBuf, uint32_t uLen);
	virtual uint32_t Send(const char *pszBuf, uint32_t uLen);

	SerialPortSetting& GetSerialPortSetting() const;
	int32_t SetSerialPortSetting(const SerialPortSetting& setting);


private:
	int32_t SetSerialPortSetting();
private:
	SerialPortSetting m_setting;
};

#endif /* SERIALPORT_H_ */
